<template>
	<view class="news-center">
		<view class="newlife-logo">
			<image src="https://dr-static-cdn.newlifegroup.com.cn/newdrmall/static/newlife.png">
			</image>
		</view>
		
		<view class="text-box">
			<view>新生活集团，因一个梦想而生的跨越中韩两国的企业</view>
			<view>新生活集团，因一个梦想而不断突破、坚守使命的综合型企业</view>
		</view>
		<view class="center-area">
			<swiper class="swiper-tall" :indicator-dots="indicatorDots" :autoplay="autoplay"
				:next-margin="nextMargin" :circular="circular" @change="change"
				:current="swiperIndex">
				<swiper-item class="swiper-container" v-for="(item, index) of promoteBgImgs" :key="index"
					:item-id="String(index)" :data-year="index" >
					<view class="swiper-item" :animation="animationData[index]" :class="{ active: swiperIndex == index }" @tap="swichMenu(index)">
						<view  class="swiper-item-inner">
							<image class="poster-bg-image" :src="item" mode="aspectFill"></image>
							<image src="https://dr-static-cdn.newlifegroup.com.cn/newdrmall/static/arrow.png"
								class="arrow-icon"></image>
						</view>
						
					</view>
				</swiper-item>
			</swiper>
		</view>
		<scroll-view class="top-tabs-view" scroll-x="true">
			<block v-for="(item,index) in tabList" :key="index">
				<view class="tabs-item-wrap" @click="swichMenu(index)">
					<view class="tabs-item">
						<view class="tabs-item-txt" :class="[currentTab==index ? 'theme-color' : '']">
							{{item}}
						</view>
						<view class="tabs-item-bottom" :class="[currentTab==index ? 'theme-color' : '']">
						</view>
					</view>
				</view>
			</block>
		</scroll-view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgSrc: this.$store.state.imgUrl,
				promoteBgImgs: [
					'https://dr-static-cdn.newlifegroup.com.cn/newdrmall/static/culture.jpg',
					'https://dr-static-cdn.newlifegroup.com.cn/newdrmall/static/trade.jpg',
					'https://dr-static-cdn.newlifegroup.com.cn/newdrmall/static/catelog.jpg'
				],
				animationData: {},
				indicatorDots: false,
				autoplay: false,
				preMargin: uni.upx2px(32) + 'px',
				nextMargin: '50px',
				circular: true,
				zoomParam: 1.0,
				swiperIndex: 0,
				data: [],
				max: 0,
				currentTab: 0,
				tabList: ['企业文化', '发展历程', '商品目录'],
			};
		},
		//第一次加载
		onLoad(options) {
			this.animation = uni.createAnimation();
			this.animation.scale(this.zoomParam).step();
			this.animationData[0] = this.animation.export();
			// #ifdef H5
			this.$wechat.noShare();
			// #endif
		},
		//方法
		methods: {
			swichMenu: async function(current) {
				this.currentTab = current;
				if (this.currentTab == 0) {
					//企业文化
					uni.navigateTo({
						url: '/packageF/pages/companyCulture/companyCulture'
					})
				} else if (this.currentTab == 1) {
					//发展历程
					uni.navigateTo({
						url: '/packageA/pages/newsInfo/companyNews'
					})
				} else {
					//es店铺商品分类
					uni.navigateTo({
						url: '/packageC/pages/storeCategory/storeCategory'
					})
				}
			},
			change(e) {
				this.swiperIndex = e.detail.current;
				this.currentTab = this.swiperIndex;
				for (let key in this.animationData) {
					if (e.detail.currentItemId == key) {
						this.animation.scale(this.zoomParam).step();
						this.animationData[key] = this.animation.export();
					} else {
						this.animation.scale(0.98, 0.9).step();
						this.animationData[key] = this.animation.export();
					}
				}
			},

		},
	};
</script>
<style lang="scss">
	.news-center {
		padding-top: 30rpx;
		padding-bottom: 60rpx;
		height: 100vh;
		overflow: hidden;
		display: flex;
		flex-direction: column;
		// align-items: center;
		justify-content: space-between;
		background-color: #fff;
		.newlife-logo {
			width: 376rpx;
			height: 116rpx;
			padding-left: 32rpx;
			image{
				width: 100%;
				height: 100%;
			}
		}

		.text-box {
			color: #999999;
			font-size: 24rpx;
			margin: 40rpx 0;
			padding-left: 32rpx;
		}

		.center-area {
			flex: 1;
			display: flex;
			width: 100%;
			align-items: center;
			padding-left: 100rpx;
		}

		.top-tabs-view {
			padding: 0 70rpx;
			margin-top: 40rpx;
			width: 100%;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-between;
			height: 76rpx;
			text-align: center;
			background-color: #fff;

			.tabs-item-wrap {
				display: inline-block;
				white-space: nowrap;
				width: 33%;
				text-align: center;

				.tabs-item {
					// margin-right: 66rpx;
					position: relative;
					height: 100%;
					display: flex;
					align-items: center;
					justify-content: center;

					.tabs-item-txt {
						height: 48rpx;
						font-size: 32rpx;
						color: #999999;

						&.theme-color {
							color: #111111;
							font-weight: bold;
						}
					}

					.tabs-item-bottom {
						position: absolute;
						bottom: 0rpx;
						width: 48rpx;
						height: 4rpx;
						border-radius: 2rpx;
						left: calc(50% - 24rpx);
						&.theme-color {
							background: #EA655E;
						}
					}
				}
			}
		}

		.swiper-tall {
			width: 100%;
			height: 100%;
			max-height:760rpx;
			display: flex;
			align-items: center;

			.swiper-container {
				display: flex;
				align-items: center;

				.swiper-item {
					height: 100%;
					width: 680upx;
					transform: scale(0.98, 0.9);
					position: relative;
					font-size: 28rpx;
					
					&.active {
						transform: scale(1);
					}
					.swiper-item-inner{
						width: 462rpx;
						height: 100%;
						background-color: #f7f7f7;
						border-radius: 32rpx;
					}
					.poster-bg-image {
						width: 462rpx;
						height: 100%;
						border-radius: 32rpx;
						
					}

					.arrow-icon {
						width: 52rpx;
						height: 52rpx;
						position: absolute;
						bottom: 40rpx;
						left: 231rpx;
						margin-left: -26rpx;
					}

				}
			}
		}
	}
</style>
